//
//  MySigninView.m
//  BigTyre
//
//  Created by 张钧 on 2017/3/28.
//  Copyright © 2017年 Lemon. All rights reserved.
//

#import "MySigninView.h"

@implementation MySigninView
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self==[super initWithFrame: frame]) {        
        //账号输入框
        _zhTF=[[UITextField alloc]initWithFrame:CGRectMake((self.frame.size.width-300)/2, (self.frame.size.height-100)/2, 300, 40)];
        //    zhTF.backgroundColor=[UIColor blueColor];
        _zhTF.placeholder=@"请输入账号";
        _zhTF.layer.masksToBounds=YES;
        _zhTF.layer.cornerRadius=15;
        _zhTF.layer.borderWidth=0.5;
        _zhTF.keyboardType=UIKeyboardTypeNumberPad;
        _zhTF.borderStyle=UITextBorderStyleRoundedRect;
        [self addSubview:self.zhTF];
        UIView * tfView1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 0)];
        //    zhTF.clearButtonMode=UITextFieldViewrModeWhileEditing;
        _zhTF.leftView=tfView1;
        _zhTF.leftViewMode=UITextFieldViewModeAlways;
        
        UIView * tfview2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
        //    tfview2.backgroundColor=[UIColor blackColor];
        _zhTF.rightView=tfview2;
        _zhTF.rightViewMode=UITextFieldViewModeAlways;
        _hq=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 40)];
        [_hq setTitle:@"获取验证码" forState:0];
        [_hq setTitleColor:[UIColor lightGrayColor] forState:0];
        _hq.titleLabel.font=[UIFont systemFontOfSize:13];
        //    [hq setBackgroundColor:[UIColor blackColor]];
        [tfview2 addSubview:self.hq];
        
        //密码输入框
        _mmTF=[[UITextField alloc]initWithFrame:CGRectMake((self.frame.size.width-300)/2, (self.frame.size.height -10)/2, 300, 40)];
        _mmTF.secureTextEntry=YES;
        _mmTF.placeholder=@"请输入密码";
        _mmTF.layer.cornerRadius=15;
        _mmTF.layer.borderWidth=0.5;
        _mmTF.layer.masksToBounds=YES;
        _mmTF.borderStyle=UITextBorderStyleRoundedRect;
        //    mmTF.backgroundColor=[UIColor cyanColor];
        [self addSubview:_mmTF];
        
        UIView * mmView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 0)];
        _mmTF.leftView=mmView;
        _mmTF.leftViewMode=UITextFieldViewModeAlways;
        _mmView2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 35, 40)];
        _mmTF.rightView=_mmView2;
        _mmTF.rightViewMode=UITextFieldViewModeWhileEditing;
        //切换明暗文
        _qh=[[UIButton alloc]initWithFrame:CGRectMake(0, 5, 30, 30)];
        [_qh setImage:[UIImage imageNamed:@"闭眼"] forState:0];
        [_qh addTarget:self action:@selector(qiehuan:) forControlEvents:UIControlEventTouchUpInside];
        [_mmView2 addSubview:_qh];
       
        
        //无法登陆
        _forget=[[UIButton alloc]initWithFrame:CGRectMake(20, 90, 50, 30)];
        [_forget setTitle:@"无法登陆" forState:UIControlStateNormal];
        [_forget setTitleColor:[UIColor grayColor] forState:UIControlStateNormal ];
        _forget.titleLabel.font=[UIFont systemFontOfSize:12];
        [self addSubview:_forget];
        
    }
    return self;
}
-(void)qiehuan:(UIButton *)send
{
    
    send.selected = !send.selected;
    if (send.selected) {
        NSString *tempPwdStr = _mmTF.text;
        _mmTF.text = @""; // 这句代码可以防止切换的时候光标偏移
        _mmTF.secureTextEntry = NO;
        _mmTF.text = tempPwdStr;
//        _qh.hidden=YES;
        [_qh setImage:[UIImage imageNamed:@"睁眼"] forState:0];

    }
    else
    {
        NSString *tempPwdStr = _mmTF.text;
        _mmTF.text = @""; // 这句代码可以防止切换的时候光标偏移
        _mmTF.secureTextEntry = YES;
        _mmTF.text = tempPwdStr;
        [_qh setImage:[UIImage imageNamed:@"闭眼"] forState:0];

//        _qh.hidden=NO;
//        _qh1.hidden=YES;

    }
}
@end
